package com.yilife.kdys.model.request;

import com.yilife.kdys.KdysRequest;
import com.yilife.kdys.Md5Helper;
import com.yilife.kdys.RequestFill;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by wuganlin on 2017/2/8.
 */
public class RegisterRequest extends KdysRequest {

    public static final String DEFAULT_PWD = "888888";

    private String mobile;
    private String name;
    private String gender;
    private Date birthday;
    private String photo;
    private String idCard;
    private String email;
    private String password;
    private String createdBy;

    @Override
    public boolean fill(HttpServletRequest request) throws Exception {
        super.fill(request);
        mobile = request.getParameter("mobile");
        name = request.getParameter("name");
        gender = request.getParameter("gender");
        if (request.getParameter("birthday") != null) {
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            birthday = format.parse(request.getParameter("birthday"));
        }
        photo = request.getParameter("photo");
        idCard = request.getParameter("idCard");
        email = request.getParameter("email");
        if (request.getParameter("password") != null) {
            password = Md5Helper.md5(request.getParameter("password"));
        } else {
            password = Md5Helper.md5(DEFAULT_PWD);
        }
        createdBy = request.getParameter("created_by");
        return true;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }
}